﻿<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>



<script RunAt="server">

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        return;
        if (!Request.Url.Host.StartsWith("www") && !Request.Url.IsLoopback)
        {
            UriBuilder builder = new UriBuilder(Request.Url);
            builder.Host = "www." + Request.Url.Host;
            Response.Redirect(builder.ToString(), true);
        }
    }

    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        BundleTable.Bundles.RegisterConfigurationBundles();
        BundleConfig.RegisterBundles(BundleTable.Bundles);

        ///Routing
        RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        RouteTable.Routes.IgnoreRoute("extjs/{*pathInfo}");
        RouteTable.Routes.IgnoreRoute("icons/{*pathInfo}");
        RouteTable.Routes.IgnoreRoute("extnet/{*pathInfo}");
        RouteTable.Routes.IgnoreRoute("ux/{*pathInfo}");
        RouteTable.Routes.IgnoreRoute("Scripts/{*pathInfo}");


        //   RouteTable.Routes.MapRoute(
        //    "Default", // Route name
        //    "{controller}/{action}/{id}", // URL with parameters
        //    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        //);

        RouteTable.Routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

        RouteTable.Routes.MapRoute(
            "List", // Route name
            "{controller}/{action}/{id}/{cId}/{title}"

        );
        RouteTable.Routes.MapRoute(
         "Detail", // Route name
         "{controller}/{action}/{id}/{title}"
     );

        ///Enable router debugger
        //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

    }

    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e)
    {
    }
    void Session_End(object sender, EventArgs e)
    {

    }
       
</script>
